package it.polito.connectedcar.message;

import it.polito.connectedcar.tcc.zone.Token;
import it.polito.connectedcar.util.Constants;

import java.util.List;

/**
 * This message is used by TrafficLights to send information to a TCC.
 * 
 * @author Nicola Aresta
 * 
 */
public class TrafficLightToTCCMessage extends OutgoingMessage {

	private int currentPhase;
	private long expectedPhaseChangeTime;
	private String tlProgram;
	private List<String> controlledLinks;
	private String trafficLightId;
	private long lastChangeTimestamp;

	public TrafficLightToTCCMessage() {
		super(Constants.TRAFFIC_LIGHT_TYPE_CODE, Constants.TRAFFIC_LIGHT_UPDATE);
	}

	@Override
	protected void convertToData(Storage st, boolean forTCC, Token t) {

		st.writeStringASCII(trafficLightId);
		st.writeInt(currentPhase);
		st.writeLong(lastChangeTimestamp);
		st.writeLong(expectedPhaseChangeTime);
	}

	public int getCurrentPhase() {
		return currentPhase;
	}

	public void setCurrentPhase(int currentPhase) {
		this.currentPhase = currentPhase;
	}

	public long getExpectedPhaseChangeTime() {
		return expectedPhaseChangeTime;
	}

	public void setExpectedPhaseChangeTime(Long expectedPhaseChangeTime) {
		this.expectedPhaseChangeTime = expectedPhaseChangeTime;
	}

	public String getTrafficLightId() {
		return trafficLightId;
	}

	public void setTrafficLightId(String trafficLightId) {
		this.trafficLightId = trafficLightId;
	}

	public List<String> getControlledLinks() {
		return controlledLinks;
	}

	public void setControlledLinks(List<String> controlledLinks) {
		this.controlledLinks = controlledLinks;
	}

	public String getTlProgram() {
		return tlProgram;
	}

	public void setTlProgram(String tlProgram) {
		this.tlProgram = tlProgram;
	}

	public void setLastChangeTimestamp(long lastChangeTimestamp) {
		this.lastChangeTimestamp = lastChangeTimestamp;
	}

	public long getLastChangeTimestamp() {
		return this.lastChangeTimestamp;
	}
}
